package com.qf.controller;

import com.qf.pojo.Order;
import com.qf.pojo.User;
import com.qf.service.OrderService;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


    @Controller
    @RequestMapping("/Order")
    public class OrderController {
        @Autowired
        private  OrderService orderService;



        @RequestMapping(value = "select", method = RequestMethod.GET)
        public String select() {
            List<Order> list = orderService.selectAll();
            for (Order order : list) {
                System.out.println(order);
            }

            /*  setAttribute("ulist", list);*/
            return "test";
        }

        @RequestMapping(value = "selectOne", method = RequestMethod.GET)
        public String selectOne() {
            Order order = orderService.selectOne(2);
            System.out.println(order);
            return "test";
        }

        @RequestMapping(value = "deleteOne/{id}", method = RequestMethod.GET)
        public String deleteOne(@PathVariable("id") int id) {
            int order2 = orderService.deleteOne(1);
            System.out.println(order2);
            return "test";
        }

        @RequestMapping(value = "update", method = RequestMethod.GET)
        public String update(Order order) {
            int order3 = orderService.update(order);
            System.out.println(order3);
            return "test";
        }


    }

